﻿<!--#include file="../mae/vbs.asp"-->
<script language="jscript" runat="server" src="Mo/Mo.js"></script>
<script language="jscript" runat="server">
define("MO_APP_NAME", "App");
define("MO_APP", "App");
define("MO_CORE", "Mo");
define("MO_PLUGIN_MODE", true);
define("MO_AUTO_CREATE_APP", false);
define("MO_DEBUG_MODE", "SESSION");
Mo.Start = function(core){
	if(core){
		define("MO_CORE", core);
	}
	if(arguments.length>1){	
		if(typeof arguments[1] == "number"){
			var ep=0;
			for(var i=1;i<arguments.length;i++) ep |= arguments[i];
			define("MO_ERROR_REPORTING", ep);
		}else{
			for(var i=1;i<=arguments.length-2;i+=2) define(arguments[i],arguments[i+1]);
		}
	}
	startup();
	Mo.Path = {};
	Mo.Path.Base = IO.parent(Mo.Config.Global['MO_CORE']).replace(F.mappath("/"),"").replace(/\\/i,"/");
	Mo.Path.Cache = Mo.Path.Base + "/Cache";
	if(typeof EASPMAE == "unknown"){
		try{
			EASPMAE();
		}catch(ex){
			MEM.put(ex.number, "MAE", ex.description);
		}
	}
}
Mo.End = function(){Mo.Terminate();};
var KeyValue, JSArray, Convert;
(function(){
	var parseAt = function(kv_, key) {
		if (!kv_.hasOwnProperty(key)) return null;
		var val = kv_[key],
			type = typeof val, type2, rel=null;
		if (type == "object") {
			type2 = Object.prototype.toString.call(val);
			if(type2 == "[object Object]"){
				rel = KeyValue();
				rel.valueOf(val);
			}else if(type2 == "[object Array]"){
				rel = JSArray();
				rel.valueOf(val);
			}
		}
		return rel;
	};
	var push = Array.prototype.push;
	KeyValue = function(){
		var _len = arguments.length, 
			kv_ = {}, 
			o = function(key, value){
				if(value === undefined) return kv_[key];
				kv_[key] = value;
			};
			o.valueOf = function(value){if(value===undefined)return kv_; kv_ = value;};
			o.valueAt = function(key, value){o.apply(this, arguments)};
			o.parseAt = function(key) { return parseAt(kv_, key);};
			
		if(_len % 2 !=0) return o;
		
		for(var i=0;i<_len;i+=2){
			kv_[arguments[i]] = arguments[i+1];
		}
		return o;
	};
	JSArray = function(){
		var kv_ = [], 
			o = function(value){
				kv_.push(value);
				push.apply(kv_, Array.prototype.slice.call(arguments, 1));
			};
			o.valueOf = function(value){if(value===undefined)return kv_; kv_ = value;};
			o.valueAt = function(key, value){if(value===undefined) return kv_[key]; kv_[key] = value;};
			o.parseAt = function(key) { return parseAt(kv_, key);};
			o.getLength = function(){return kv_.length;};
		
		push.apply(kv_, arguments);
		return o;
	};
	Convert = function(arg){
		var type = typeof arg;
		if(type == "string") {
			return Convert.ToFunction(arg);
		}
		if(type == "unknown"){ 
			if(arg.constructor == VBArray){
				return Convert.ToJSArray(arg);
			}
		}
		if(type == "date") return new Date(dt);
		if(type == "object"){
			if(arg instanceof Array){
				return Convert.ToVBArray(arg);
			}else{
				return Convert.ToFunction(arg);
			}
		}
	};
	Convert.ToJSArray = function(vbarray){
		var o = JSArray();
		o.valueOf((new VBArray(vbarray)).toArray());
		return o;
	};
	Convert.ToVBArray = function(jsarray){
		var o = JSArray();
		o.valueOf(jsarray);
		return convert2vbarray(o);
	};
	Convert.ToFunction = function(fn){
		(typeof fn == "string") && (fn = mae_get_ref(fn));
		return function(){
			return Function.prototype.apply.apply(fn, [this,arguments]);
		}
	};
	Convert.ToDate = function(dt){
		if(typeof dt == 'date') return new Date(dt);
		return dt;
	};
	Convert.ToString = function(str){
		return new String(str);
	};
})();
</script>